<template>
    <i :class="classes" :style="styles"></i>
</template>
<script>
    import {oneOf} from '../../utils/assist';

    const prefixCls = 'ivu-icon';

    export default {
        name: 'Icon',
        props: {
            type: String,
            size: [Number, String],
            color: String
        },
        computed: {
            classes () {
                return [
                    `${prefixCls} ${prefixCls}-${this.type}`,
                    {
                        [`${prefixCls}-${this.color}`]: oneOf(this.color, ['primary', 'info', 'success', 'warning', 'error'])
                    }
                ];
            },
            styles () {
                let style = {};

                if (this.size) {
                    style['font-size'] = `${this.size}px`;
                }

                if (this.color && !oneOf(this.color, ['primary', 'info', 'success', 'warning', 'error'])) {
                    style.color = this.color;
                }

                return style;
            }
        }
    };
</script>
